<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="cn">
<head>
<meta name="renderer" content="webkit"/>
<%@ include file="/common/meta.jsp"%>
<title>${applicationScope.siteName }</title>
</head>
<body class="no-skin">
	<c:if test="${not repairManager and not facilityRepairManager}">
	<%@ include file="/common/header.jsp"%>
	</c:if>
	<c:if test="${repairManager or facilityRepairManager}">
	<%@ include file="/common/header_repair.jsp"%>
	</c:if>
	<div class="main-container" id="main-container">
		<script type="text/javascript">
			try {
				ace.settings.check('main-container', 'fixed');
				
			} catch (e) {
			}
		</script>
		<%@ include file="/common/sidebar.jsp"%>
	 
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<%@ include file="/common/settingsbox.jsp"%>
					<div id="tabs">
						<ul class="nav nav-tabs" id="myTab">
							<li class="active"><a data-toggle="tab" href="#home"> <i class="ace-icon fa fa-home bigger-120"></i>控制台
							</a></li>
						</ul>
						<div id="myTabContent">
							<div id="home" class="active">
								<div class="row">
									<div class="col-sm-6">
										<div class="widget-box">
											<div class="widget-header">
												<h4 class="widget-title lighter smaller">
													<i class="ace-icon fa fa-comment blue"></i> 公告
												</h4>
											</div>
											<div class="widget-body">
												<div class="widget-main no-padding">
													<div class="notices">
														<!-- #section:pages/timeline -->
														<div class="timeline-container">
															<c:forEach items="${noticeList}" var="notice">
																<div class="timeline-items">
																	<div class="timeline-item clearfix">
																		<div class="timeline-info">
																			<i class="timeline-indicator ace-icon fa fa-leaf btn btn-primary no-hover green"></i>
																		</div>
																		<div class="widget-box transparent">
																			<div class="widget-header widget-header-small">
																				<h5 class="widget-title smaller">${notice.noticeTitle }</h5>
																				<span class="widget-toolbar"><a href="#" data-action="collapse"> <i class="ace-icon fa fa-chevron-up"></i>
																				</a> </span> <span class="widget-toolbar no-border"> <i class="ace-icon fa fa-clock-o bigger-110"></i>
																					${fn:substring(notice.createTime,0,16)}
																				</span>
																			</div>
																			<div class="widget-body">
																				<div class="widget-main">${notice.noticeContent }</div>
																			</div>
																		</div>
																	</div>
																</div>
																<!-- /.timeline-items -->
															</c:forEach>
														</div>
														<!-- /.timeline-container -->
													</div>
												</div>
												<!-- /.widget-main -->
											</div>
											<!-- /.widget-body -->
										</div>
										<!-- /.widget-box -->
									</div>
									<div class="col-xs-12 col-sm-6"></div>
								</div>
							</div>
							<div id='context-menu'>
								<ul class='dropdown-menu' role='menu'>
									<!-- <li align="center"><a tabindex='-1' href='#' onclick="javascript:window.parent.location.reload()">关闭所有窗口</a></li> -->
									<li align="center"><a tabindex='-1' href='#' onclick="closeAll()">关闭所有窗口</a></li>
									<li align="center"><a tabindex='-1' href='#' onclick="closeOthers()">关闭其他窗口</a></li>
									<li role="separator" class="divider"></li>
									<li align="center"><a tabindex='-1' href='#' onclick="closeThis()">关闭当前窗口</a></li>
								</ul>
							</div>
						</div>
					</div>
					<!-- /.page-content -->
					<%-- <%@ include file="/common/footer.jsp"%> --%>
				</div>
			</div>
		</div>
		<!-- /.main-content -->
	</div>
	<!-- /.main-container -->
	
	<div id="dlg" class=" hidden"  >
		<div id="dialog"  class=" widget-box  "  title="初始化人员信息"  >
		      <table id="tbl">
		      		<tr>
						<td colspan="2">
							<div  style="font-size:14px;margin:5px auto;color:#9B59B6;border-bottom:1px dotted  #9B59B6;">该系统会发送整改要求的提示短信，需要您输入手机号码配合：</div>
						</td>
					</tr>		      		
				    <tr>
				       <td><span>手机号：</span></td> 
					   <td><input id="phone" name="phone" ></td>
					</tr>
					<tr>
						<td colspan="2">
							<div  style="font-size:14px;margin:5px auto;color:#9B59B6;border-bottom:1px dotted  #9B59B6;">第一次登陆，请修改密码：</div>
						</td>
					</tr>		      		
				    <tr>
						<td><label>新&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码：</label></td>
						<td><input id="newPassword" name="newPassword"
							type="password" class="easyui-validatebox" required="required">
						</td>
					</tr>
					<tr>
						<td><label>请重复输入密码：</label></td>
						<td><input id="newPasswordA" name="newPasswordA"
							type="password" class="easyui-validatebox"
							validType="equals['#newPassword']" required="required"></td>
					</tr>
				</table>
		</div>
	</div> 	
											
	<%@ include file="/common/script.jsp"%>
	<!-- inline scripts related to this page -->
	<script type="text/javascript">
		window.onload=function(){
			addTab('2c9689d04688a380014688a88f91000d', '待办任务', '${ctx}/bpm/workspace/to-workspace-listPersonalTasks', null, null);
		}
		var curMenuId = 'dashboard', curPmenuId, curRmenuId, tabs, tabCount = 1, tabsArray = [ 'dashboard' ];
		jQuery(function($) {
			 
			 <c:if test="${phoneFlag }">

			 
					  $( "#dialog" ).dialog({ 
						 modal:true,
						 width:500,
						 open: function (event, ui) { $(".ui-dialog-titlebar-close", $(this).parent()).hide();
				           },
				           buttons: { "保存": function() {
				        	   if($('#newPassword').val().length<6){
				        		   alert("密码长度必须不少于6位")
				        	   }
				        	   var  re = /^[1][3,4,5,7,8][0-9]{9}$/;  
				        	   if (re.test($('#phone').val())) {
				        		   $.post("${ctx}/basic/user/savePhone", {
				   					phone : $('#phone').val(),
				   					newPassword : $('#newPassword').val(),
				   					newPasswordA : $('#newPasswordA').val()
				   				}, function(data) {
				   					if(data.success){
					   					alert(data.msg);
					   					$("#dialog" ).dialog('close');
				   					}else{
				   						alert(data.msg);
				   					}
				   				}, "json");
				        	    } else {
				        	        alert("请输入正确的手机号，以免您错过提示短信消息，耽误工作！");
				        	    }
				        	   
				           } }  
				      }); 
			 </c:if>
			 
		 
			ace.settings.navbar_fixed(null, true);
			ace.settings.sidebar_fixed(null, true);
			tabs = $("#tabs").tabs();

			$('.notices').ace_scroll({
				size : 450
			});			
		 
		});
		// actual addTab function: adds new tab using the input from the form above
		function addTab(menuId, menuName, menuUrl, pmenuId, rmenuId) {

			if (curMenuId != menuId) {
				$("#menu" + curMenuId).removeClass("active").removeClass("open");
				curPmenuId && $("#menu" + curPmenuId).removeClass("active").removeClass("open");
				curRmenuId && $("#menu" + curRmenuId).removeClass("active").removeClass("open");
				curMenuId = menuId;
				curPmenuId = pmenuId;
				curRmenuId = rmenuId;
			}
			pmenuId && $("#menu" + pmenuId).addClass("active open");
			rmenuId && $("#menu" + rmenuId).addClass("active open");
			$("#menu" + menuId).addClass("active");
			for (var i = 0; i < tabsArray.length; i++) {
				if (tabsArray[i] == menuId) {
					tabs.tabs({
						active : i
					});
					//dj
					refreshCurrTab();
					//---------------------
					return true;
				}
			}
			++tabCount;

			$("#myTab")
					.append(
							"<li><a data-toggle='tab' href='#"+ menuId +"'>"+"<div id='context' data-toggle='context' data-target='#context-menu'>"+"<span class='ace-icon glyphicon glyphicon-repeat tab-refresh' style='cursor: pointer;'></span> "
									+ "<span class='tab-reCall' style='cursor: pointer;'>"+ menuName+"</span>"
									+ "<span class='ace-icon glyphicon glyphicon-remove tab-close red' style='cursor: pointer;'></span></div></a></li>");
			$("#myTabContent").append(
					"<div id='"+ menuId +"' class='tab-pane'>" + "<iframe style='width:100%;height:" + ($(document).height() - 93)
							+ "px;padding:0px;' scrolling='auto' frameborder='0' id='centerIframe' src='" + menuUrl + "'></iframe></div>");
			tabs.tabs("refresh").tabs("load", tabsArray.length).tabs({
				active : tabsArray.length,
				collapsible : false
			}); 
			tabs.delegate(".tab-close", "click", function() {
				var panelId = $(this).closest("li").remove().attr("aria-controls");
				$("#" + panelId).remove();
				tabs.tabs("refresh");
				for (var i = 0; i < tabsArray.length; i++) {
					if (tabsArray[i] == panelId) {
						tabsArray.splice(i, 1);
						tabs.tabs({
							active : i - 1
						});
						//dj
						curMenuId=tabsArray[i-1];
						if($("li[aria-controls="+(tabsArray[i-1])+"]").text()==" 待办任务"){							
							refreshCurrTab();
						}
						//---------------------
						continue;						
					}					
				}
			});
			tabs.delegate(".tab-refresh", "click", function(e) {
				var panelId = $(this).closest("li").attr("aria-controls");
				$("#" + panelId).find("iframe").get(0).contentWindow.location.reload();
				for (var i = 0; i < tabsArray.length; i++) {
					if (tabsArray[i] == panelId) {
						tabs.tabs({
							active : i
						});
						return true;
					}
				}
				e.stopPropagation();
				return false;
			});
			tabs.delegate(".tab-reCall", "click", function(e) {
				var panelId = $(this).closest("li").attr("aria-controls");
				curMenuId = panelId;
				//$("#" + panelId).find("iframe").get(0).contentWindow.location.reload();
				for (var i = 0; i < tabsArray.length; i++) {
					if (tabsArray[i] == panelId) {
						tabs.tabs({
							active : i
						});
						//dj
						if($(this).text()=='待办任务'){
							refreshCurrTab();
						}
						//---------------------
						return true;
					}
				}
				e.stopPropagation();
				return false;
			});
			tabsArray[tabsArray.length] = menuId;
		}
	
		// 刷新当前tabs
		function refreshCurrTab() {
			$("#" + curMenuId).find("iframe").get(0).contentWindow.location.reload();
			for (var i = 0; i < tabsArray.length; i++) {
				if (tabsArray[i] == curMenuId) {
					tabs.tabs({
						active : i
					});
				}
			}
		}
		//关闭所有窗口
		function closeAll(){	
			//window.parent.location.reload();
			for (var i = 1; i < tabsArray.length; i++) {
				$("li[aria-controls="+tabsArray[i]+"]").remove();
				$("#" + tabsArray[i]).remove();
				tabs.tabs("refresh");
			}
			tabsArray.splice(1, tabsArray.length-1);
			tabs.tabs({
				active : 0
			});
		}
		//关闭其他窗口
		function closeOthers() {
			var newArray="";
			for (var i = 1; i < tabsArray.length; i++) {
				if (tabsArray[i] == curMenuId) {			
					newArray=tabsArray.splice(i, 1);
					i--;
				}else{
					$("li[aria-controls="+tabsArray[i]+"]").remove();
					$("#" + tabsArray[i]).remove();
					tabs.tabs("refresh");
				}
			}
			tabsArray.splice(1,tabsArray.length-1,newArray);
			tabs.tabs({
				active : 1
			});
		}
		//关闭当前窗口
		function closeThis() {
			$("li[aria-controls="+curMenuId+"]").remove();
			$("#" + curMenuId).remove();
			tabs.tabs("refresh");
			for (var i = 0; i < tabsArray.length; i++) {
				if (tabsArray[i] == curMenuId) {
					tabsArray.splice(i, 1);
					if(i==1&&tabsArray.length>1){
						curMenuId = tabsArray[i];
						tabs.tabs({
							active : i
						});
					}else{
						tabs.tabs({
							active : i - 1
						});
						if((i - 1)>0){
							curMenuId = tabsArray[i-1];
						}
					}
					break;
				}
			}
		}
	</script>
</body>
</html>
